#include <cstdio>
#include <stack>
#include <queue>

using namespace std;

int main( )
{
    int i, j, k, opt[ 101 ], len ;
    char data[ 101 ];
    stack<bool> s;
    queue<bool> q;
    bool ok;
    while ( gets( data ) )
    {
        len = strlen( data );
        opt[ 0 ] = 0;
        for ( i = 1; i < len; i++ )
            opt[ i ] = 0xffffff;
        for ( i = 1; i < len; i++ )
        {
            for ( j = i; j >= 0; j-- )
            {
                while ( !s.empty( ) )
                    s.pop( );
                while ( !q.empty( ) )
                    q.pop( );
                for ( k = j; k <= i; k++ )
                {
                    s.push( data[ k ] == 'X' );
                    q.push( data[ k ] == 'X' );
                }
                ok = true;
                while ( !q.empty( ) )
                {
                    if ( q.front( ) != s.top( ) )
                    {
                        ok = false;
                        break;
                    }
                    q.pop( );
                    s.pop( );
                }
                if ( ok )
                {
                    if ( j == 0 )
                        opt[ i ] = 0;
                    else
                        if ( opt[ i ] > opt[ j - 1 ] + 1 )
                            opt[ i ] = opt[ j - 1 ] + 1;
                }
            }
        }
        printf("%d\n", opt[ len - 1 ]);
    }
    return 0;
}
